package org.lost.design.factory.simple;

import org.lost.design.factory.CheesePizza;
import org.lost.design.factory.Pizza;
import org.lost.design.factory.PizzaType;
import org.lost.design.factory.VeggiePizza;
import org.lost.design.factory.abstracts.NYPizzaIngredientFactory;

public class SimpleFactory {
    
    public Pizza createPizza(PizzaType type) {
        Pizza pizza = null;
        switch (type) {
            case Chessse:
                pizza = new CheesePizza(new NYPizzaIngredientFactory());
                break;
            case Veggie:
                pizza = new VeggiePizza();
                break;
            default:
                break;
        }
        return pizza;
    }
    
    /**
     * 常用的简单工厂方法为静态方法
     * @param type
     * @return
     * 
     * @returns Pizza
     * @see [类、类#方法、类#成员]
     * @author  zhangpeijun[zhangpeijun1024@qq.com]<br/>
     *          2017年12月22日上午10:14:12
     */
    public static Pizza commonCreatePizza(PizzaType type) {
        Pizza pizza = null;
        switch (type) {
            case Chessse:
                pizza = new CheesePizza(new NYPizzaIngredientFactory());
                break;
            case Veggie:
                pizza = new VeggiePizza();
                break;
            default:
                break;
        }
        return pizza;
    }
}
